onPrepare
Called when an insets animation is about to start and before the views have been re-laid out due to an animation.
This ordering allows the application to inspect the end state after the animation has finished, and then revert to the starting state of the animation in the first onProgress callback by using post-layout view properties like setX and related methods.
The ordering of events during an insets animation is the following:
- Application calls hide, show, controlWindowInsetsAnimation
- onPrepare is called on the view hierarchy listeners
- onApplyWindowInsets will be called with the end state of the animation
- View hierarchy gets laid out according to the changes the application has requested due to the new insets being dispatched
- onStart is called before the view hierarchy gets drawn in the new laid out state
- onProgress is called immediately after with the animation start state
- The frame gets drawn.
Note: If the animation is application controlled by using controlWindowInsetsAnimation, the end state of the animation is undefined as the application may decide on the end state only by passing in shown
parameter when calling finish. In this situation, the system will dispatch the insets in the opposite visibility state before the animation starts. Example: When controlling the input method with controlWindowInsetsAnimation and the input method is currently showing, onApplyWindowInsets will receive a WindowInsetsCompat instance for which isVisible will return false
for ime.
Parameters
The animation that is about to start.